package com.itheima.d03_thread_callable;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class Test {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        //需求：同时统计1——100的偶数和，统计100的奇数和
        MycallableOne c1=new MycallableOne();
//4.创建Callable接口实现类的对象
        FutureTask<Integer> ft1=new FutureTask<>(c1);
        Thread thread=new Thread(ft1);
        thread.start();
        int  sum=1;
        for (int i = 3; i < 100; i+=2){
            sum+=i;
            System.out.println(" 主线程");

        }
        System.out.println("主线程结果："+sum);

        //get()方法会阻塞当前线程，会等待获取call()方法返回结果

        Integer result1=ft1.get();
        System.out.println("偶数和为："+result1);


    }
}
